<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>全局配置</title>
    <link href="../../resource/css/bootstrap.min.css?v=3.3.5" rel="stylesheet"
          th:href="@{/resource/css/bootstrap.min.css?v=3.3.5}"/>
    <link href="../../resource/hotui/css/font-awesome.min.css" th:href="@{/resource/hotui/css/font-awesome.min.css}"
          rel="stylesheet">
    <!-- Morris -->
    <link href="../../resource/hotui/css/plugins/morris/morris-0.4.3.min.css"
          th:href="@{/resource/hotui/css/plugins/morris/morris-0.4.3.min.css}" rel="stylesheet">
    <link href="../../resource/css/animate.min.css" rel="stylesheet" th:href="@{/resource/css/animate.min.css}"/>
    <link href="../../resource/hotui/css/style.min-1.0.8.css" th:href="@{/resource/hotui/css/style.min-1.0.8.css}"
          rel="stylesheet">
    <!--    <link href="../../resource/hotui/css/hotui.style.override.css"-->
    <!--          th:href="@{/resource/hotui/css/hotui.style.override.css}" rel="stylesheet"/>-->
    <!--    <link href="../../resource/lib/imageview/css/imageviewer.css" rel="stylesheet"/>-->
    <style>
        #edit_form button {
            padding: 4px 12px;
        }

        .hr-line-dashed {
            margin: 15px 0;
        }

        .form-control {
            display: inline-block;
            margin-right: 5px;
        }

        .form-control.OnlyFloat,
        .form-control.OnlyNum {
            width: 100px;
        }

        .form-title {
            width: 100%;
            font-weight: 500;
            font-size: 14px;
            border-bottom: 1px solid #f5f5f5;
            padding-bottom: 10px;
            margin-bottom: 10px;
        }
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="row">
        <div class="ibox float-e-margins m-b-none">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active"><a class="tab1" data-toggle="tab" href="#tab-1"
                                              aria-expanded="true">数农基本配置</a>
                        </li>
                        <li class=""><a class="tab2" data-toggle="tab" href="#tab-2"
                                        aria-expanded="true">积分奖励配置</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <!--基本配置-->
                        <div id="tab-1" class="tab-pane active">
                            <div class="panel-body">
                                <form class="form-horizontal" id="zbConfig">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">当前打假数量</label>
                                        <div class="col-sm-6">
                                            <input type="text" value="100" id="currentDjCount" name="currentDjCount"
                                                   maxlength="30" class="form-control only-num" style="width: 80px;"
                                                   th:value="${config.zbConfig.currentDjCount}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">增长频率</label>
                                        <div class="col-sm-6">
                                            每 <input type="text" value="10" id="addFrequency" name="addFrequency"
                                                     maxlength="30" class="form-control only-num" style="width: 80px;"
                                                     th:value="${config.zbConfig.addFrequency}"> 分钟,增长1个,最低10分钟
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">每天增长的最大值</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="5" id="toDayMaxAddCount"
                                                   name="toDayMaxAddCount" style="width: 50px;"
                                                   maxlength="30" class="form-control only-num"
                                                   th:value="${config.zbConfig.toDayMaxAddCount}">个,今日已增长<span
                                                style="color: red" th:text="${config.zbConfig.toDayAddCount}">1</span>个
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">直播间官方公告内容</label>
                                        <div class="col-sm-6">
                                            <textarea id="liveNotice" name="liveNotice"
                                                      maxlength="30" class="form-control" style="width: 400px;"
                                                      th:text="${config.zbConfig.liveNotice}"
                                                      placeholder="直播间公告内容"></textarea>
                                        </div>
                                    </div>


                                    <div class="form-title">其他配置</div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">升级会员费用</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="288" id="upgradeAmount"
                                                   name="upgradeAmount" style="width: 80px;"
                                                   maxlength="30" class="form-control only-float"
                                                   th:value="${config.basicsConfig.upgradeAmount}">元
                                        </div>
                                    </div>


                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">拍卖违约次数</label>
                                        <div class="col-sm-8">
                                            违约 <input type="text" value="3" id="payTimeoutCount"
                                                      name="payTimeoutCount" style="width: 50px;"
                                                      maxlength="30" class="form-control only-num"
                                                      th:value="${config.basicsConfig.payTimeoutCount}">次后，需要缴纳保证金
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">拍卖保证金</label>
                                        <div class="col-sm-8">
                                            违约<span class="payTimeoutCount"
                                                    th:text="${config.basicsConfig.payTimeoutCount}">3</span>次，
                                            需缴纳保证金 <input type="text" value="0" id="securityDepositFirst"
                                                          name="securityDepositFirst" style="width: 100px;"
                                                          maxlength="30" class="form-control only-float"
                                                          th:value="${config.basicsConfig.securityDepositFirst}">元，
                                            大于<span class="payTimeoutCount"
                                                    th:text="${config.basicsConfig.payTimeoutCount}">3</span>次,
                                            需缴纳保证金 <input type="text" value="0" id="securityDepositTwo"
                                                          name="securityDepositTwo" style="width: 100px;"
                                                          maxlength="30" class="form-control only-float"
                                                          th:value="${config.basicsConfig.securityDepositTwo}">元
                                        </div>
                                    </div>
                                </form>
                                <div class="form-group" style="margin-top: 10px;">
                                    <div class="col-sm-8 col-sm-offset-2">
                                        <button class="btn btn-success btn-submit" type="button"
                                                onclick="jsHelper.btnSubmit()">保存配置
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>


                        <!--签到配置-->
                        <div id="tab-2" class="tab-pane">
                            <div class="panel-body">
                                <form class="form-horizontal" style="margin-left: 80px" id="signConfig">
                                    <div class="form-group">
                                        <div class="col-sm-8">
                                            第一天签到，奖励
                                            <input type="text" value="5" id="rewardIntegral1"
                                                   name="rewardIntegral1" style="width: 50px;"
                                                   maxlength="30" class="form-control only-num"
                                                   th:value="${config.signConfig.rewardConfig[0].rewardIntegral}">个积分
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-8">
                                            第二天签到，奖励
                                            <input type="text" value="5" id="rewardIntegral2"
                                                   name="rewardIntegral2" style="width: 50px;"
                                                   maxlength="30" class="form-control only-num"
                                                   th:value="${config.signConfig.rewardConfig[1].rewardIntegral}">个积分
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-8">
                                            第三天签到，奖励
                                            <input type="text" value="5" id="rewardIntegral3"
                                                   name="rewardIntegral3" style="width: 50px;"
                                                   maxlength="30" class="form-control only-num"
                                                   th:value="${config.signConfig.rewardConfig[2].rewardIntegral}">个积分
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-8">
                                            第四天签到，奖励
                                            <input type="text" value="5" id="rewardIntegral4"
                                                   name="rewardIntegral4" style="width: 50px;"
                                                   maxlength="30" class="form-control only-num"
                                                   th:value="${config.signConfig.rewardConfig[3].rewardIntegral}">个积分
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-8">
                                            第五天签到，奖励
                                            <input type="text" value="5" id="rewardIntegral5"
                                                   name="rewardIntegral5" style="width: 50px;"
                                                   maxlength="30" class="form-control only-num"
                                                   th:value="${config.signConfig.rewardConfig[4].rewardIntegral}">个积分
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-8">
                                            第六天签到，奖励
                                            <input type="text" value="5" id="rewardIntegral6"
                                                   name="rewardIntegral6" style="width: 50px;"
                                                   maxlength="30" class="form-control only-num"
                                                   th:value="${config.signConfig.rewardConfig[5].rewardIntegral}">个积分
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-8">
                                            第七天签到，奖励
                                            <input type="text" value="5" id="rewardIntegral7"
                                                   name="rewardIntegral7" style="width: 50px;"
                                                   maxlength="30" class="form-control only-num"
                                                   th:value="${config.signConfig.rewardConfig[6].rewardIntegral}">个积分
                                        </div>
                                    </div>

                                    <div class="form-group" style="display: none">
                                        <div class="col-sm-8">
                                            关注公众号，奖励
                                            <input type="text" value="0" id="subscribeRewardIntegral"
                                                   name="subscribeRewardIntegral" style="width: 50px;"
                                                   maxlength="30" class="form-control only-num"
                                                   th:value="${config.signConfig.subscribeRewardIntegral}">个积分
                                        </div>
                                    </div>

                                </form>
                                <div class="form-group" style="margin-top: 10px;">
                                    <div class="col-sm-8 col-sm-offset-1">
                                        <button class="btn btn-success btn-submit" type="button"
                                                onclick="jsHelper.btnSubmitSign()">保存积分奖励配置
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="../../resource/js/jquery.min.js?v=2.1.4" th:src="@{/resource/js/jquery.min.js?v=2.1.4}"></script>
<script src="../../resource/js/bootstrap.min.js?v=3.3.5" th:src="@{/resource/js/bootstrap.min.js?v=3.3.5}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js(123123)}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-init.js(12312)}"></script>

<script type="text/javascript" th:inline="javascript">
    const editUri = /*[[@{/config/ajax/save}]]*/  "";
    const editSignUri = /*[[@{/config/ajax/save/sign}]]*/  "";
</script>
<script type="text/javascript">
    let jsHelper = {
        btnSubmit: function () {
            let self = this;
            let zbConfig = $("#zbConfig").parseForm();
            zbConfig.liveNotice = $("#liveNotice").val();
            let param = {};
            $.extend(param, zbConfig);
            hot.ajax(editUri, param, function (ret) {
                if (ret.resultCode === 2000) {
                    hot.tip.success("提交成功", function () {
                        // window.location.reload();
                    });
                } else {
                    hot.tip.error(ret.resultMsg);
                }
            }, () => {
            }, "post");
        },
        btnSubmitSign() {
            let self = this;
            $("#signConfig .only-num").each(function () {
                let value = $(this).val();
                if (typeof value === "undefined" || value.length === 0 || isNaN(value)) {
                    $(this).val(0);
                }
            });

            let rewardIntegral1 = $("#rewardIntegral1").val();
            let rewardIntegral2 = $("#rewardIntegral2").val();
            let rewardIntegral3 = $("#rewardIntegral3").val();
            let rewardIntegral4 = $("#rewardIntegral4").val();
            let rewardIntegral5 = $("#rewardIntegral5").val();
            let rewardIntegral6 = $("#rewardIntegral6").val();
            let rewardIntegral7 = $("#rewardIntegral7").val();
            let subscribeRewardIntegral = $("#subscribeRewardIntegral").val();
            let rewardConfig = [];
            rewardConfig.push({day: 1, rewardIntegral: parseInt(rewardIntegral1)});
            rewardConfig.push({day: 2, rewardIntegral: parseInt(rewardIntegral2)});
            rewardConfig.push({day: 3, rewardIntegral: parseInt(rewardIntegral3)});
            rewardConfig.push({day: 4, rewardIntegral: parseInt(rewardIntegral4)});
            rewardConfig.push({day: 5, rewardIntegral: parseInt(rewardIntegral5)});
            rewardConfig.push({day: 6, rewardIntegral: parseInt(rewardIntegral6)});
            rewardConfig.push({day: 7, rewardIntegral: parseInt(rewardIntegral7)});

            let param = {
                rewardConfig: JSON.stringify(rewardConfig),
                subscribeRewardIntegral: parseInt(subscribeRewardIntegral)
            };
            hot.ajax(editSignUri, param, function (ret) {
                if (ret.resultCode === 2000) {
                    hot.tip.success("提交成功", function () {

                    });
                } else {
                    hot.tip.error(ret.resultMsg);
                }
            }, () => {
            }, "post");
        }
    };
    $(function () {

        $("#payTimeoutCount").change(function () {
            $(".payTimeoutCount").text(this.value);
        });
    });
</script>
</body>

</html>
